package org.walkerljl.boss.service.auth.impl;

import org.springframework.stereotype.Service;
import org.walkerljl.boss.dao.auth.RoleResMappDao;
import org.walkerljl.boss.domain.auth.RoleResMapp;
import org.walkerljl.boss.service.auth.RoleResMappService;
import org.walkerljl.boss.support.dao.BaseDao;
import org.walkerljl.boss.support.service.impl.BaseServiceImpl;
import org.walkerljl.commons.util.CollectionUtils;
import org.walkerljl.commons.util.ListUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * RoleResMappServiceImpl
 *
 * @author lijunlin
 */
@Service("roleResMappService")
public class RoleResMappServiceImpl extends BaseServiceImpl<Long, RoleResMapp> implements RoleResMappService {

    @Resource
    private RoleResMappDao roleResMappDao;

    @Override
    public BaseDao<Long, RoleResMapp> getDao() {
        return roleResMappDao;
    }

    @Override
    public List<RoleResMapp> queryByRoleIds(List<Long> roleIds) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public List<Long> queryAuthResCodeIdsByRoleIds(List<Long> roleIds) {
        if (CollectionUtils.isEmpty(roleIds)) {
            return null;
        }
        List<RoleResMapp> roleResMapps = queryByRoleIds(roleIds);
        if (CollectionUtils.isEmpty(roleResMapps)) {
            return null;
        }
        List<Long> resCodeIds = ListUtils.newArrayList();
        for (RoleResMapp roleResMapp : roleResMapps) {
            if (roleResMapp.isEnabled()) {
                resCodeIds.add(roleResMapp.getResCodeId());
            }
        }
        return resCodeIds;
    }
}